<div class="right_side_operate_area">
    <div class="right_side_title left">
        <h2><?php echo $group['Group']['group_name'] ; ?></h2>
    </div>
    <div class="right back_btn"><?php echo $html->link("返回","/groups/index/")?></div>
    <div class="clear"></div>
</div>
<?php $cuser = $session->read('User'); ?>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="group_panel">
            <div class="member_area">
                <div class="member_head">
                    <div class="memeber_title">部门描述</div>
                </div>
                <div class="member_body">
                    <p><?php echo $group['Group']['remark'] ; ?></p>
                </div>
            </div>
            <div class="member_area">
                <div class="member_head">
                    <div class="memeber_title left"><?php  __('Members') ;?></div>
                  <!--  <?php if($cuser['isadmin']|| ($cuser['isgroupadmin'] && $cuser['group_id'] == $group['Group']['id'])){ ?>
                    <div class="right member_manage"><a href="javascript:void(0);" class="manage_user_toggle"><?php echo "添加成员"; ?></a></div>
                    <?php } ?>
                    <div class="manage_user_panel clear" style="display:none;">
                        <div class="users_form">
                        <?php if($imuser){ ?>
                            <?php echo $form->create('Group', array('action' => 'addusers','type'=> 'post','id' => 'form','name' => 'form') ); ?>
                            <ul>
                                <?php
                                
                                    foreach($imuser as $key=>$im){
                                ?>
                                <li>
                                    <?php if($im['Attachment']['file_path']){ ?>
                                        <div class="member_portrait"><?php  echo $html->image("/".$im['Attachment']['file_path']);?></div>
                                    <?php }else{ ?>
                                        <div class="member_portrait"><?php echo $html->image("contact.jpg");?></div>
                                    <?php } ?>
                                    
                                    <div class="member_name"><?php echo $form->text('immembers',array('type'=>'checkbox','value'=> $key,'name'=>'immembers[]')).$im['User']['username']; ?></div>
                                    
                                </li>
                                <?php
                                    }
                                
                                ?>
                                <div class="clear"></div>
                            </ul>
                            <?php echo $form->input('groupid',array('type'=>'hidden','value'=> $group['Group']['id'],'name'=>'groupid')); ?>
                            <?php echo $form->submit(__('Save',true), array("id"=>"manageuser","name"=>"submit","class"=>"buttom","div"=>false)); ?>
                            <?php }else{ 
                            echo '<span class="error_message">没有用户</span>';
                            }
                            ?>
                        </div>
                    </div>
                    -->
                    <div class="clear"></div>
                </div>
                                
                <div class="member_body">
                    <div class="member_list">
                        <ul>
                            <?php
                            foreach($inmembers as $u){
                                 $a=$u['Attachment'];
                               $u=$u['User'];
                               
                               
                             
                            ?>
                            <li class="per_member">
                                <div class="member_portrait">
                                    <div class="member_photo">
                                        <?php if($u['isgroupadmin']){ ?>
                                            <div class="admin_tag"><?php echo $html->image("user_admin.png");?></div>
                                        <?php } ?>
                                        <?php if($u['photo_id']){ ?>
                                            <div class="profile_size">
                                            <?php 
                                             // var_dump($a['file_path']);die;
                                            if($a['file_path']){
                                                
                                                echo $html->image("/".$a['file_path'],array("url"=>"/users/view/".$u['id']));
                                            }else{ echo $html->image("contact.jpg",array("url"=>"/users/view/".$u['id']));}
                                            ?>
                                            </div>
                                        <?php }else{ echo $html->image("contact.jpg",array("url"=>"/users/view/".$u['id']));} ?>
                                        
                                    </div>
                                    <?php  if(1==2 && $cuser['isadmin'] || ($cuser['isgroupadmin'] && $cuser['groupid'] == $group['Group']['id'])){?>
                                    <div class="member_oper">
                                        <div class="member_oper_arrow"></div>
                                        <ol>
                                            <?php 
                                            if(empty($u['isgroupadmin'])){ ?>
                                            <li><?php echo $html->link(__('make admin',true), array('action' => 'makeadmin', $u['id']), null, null); ?></li>
                                            <?php  }else{ ?>
                                            <li>
                                            <?php echo $html->link(__('remove admin',true), array('action' => 'removeadmin', $u['id']), null, null); ?>
                                            </li>
                                            <?php } ?>
                                            <li><?php echo $html->link(__('Delete',true), array('action' => 'deleteuser', $u['id']), null, null); ?></li>
                                           
                                        </ol>
                                    </div> 
                                    <?php  } ?> 
                                </div>
                                <div class="member_name"><?php echo $html->link($u['name'],"/users/view/".$u['id']);?></div>
                            </li>
                            <?php } ?>
                            <div class="clear"></div>
                        </ul>
                    </div>
                </div>
                                
            </div>
        </div>
    </div>
</div>
<script type=text/javascript>
    var webpath=$("#getpath").attr('href');
    function deluser(obj,groupid,userid){
        $.ajax({     	   
                url: webpath+'groups/deleteuser?groupid='+encodeURI(groupid)+'&userid='+encodeURI(userid) , 
                success:function(data){	
                showmessage('操作成功');
                $(obj).parent().parent().parent().parent().parent().remove();
                $("#user"+userid).remove();	    			
                }       
             });
             return false;
    }
    function makeadmin(groupid,userid){
        $.ajax({     	   
                url: webpath+'groups/makeadmin?groupid='+encodeURI(groupid)+'&userid='+encodeURI(userid) , 
                success:function(data){
                //window.location.reload();
                //location.reload();
                // showmessage('操作成功');
                }       
             });
    }
    function removeadmin(groupid,userid){
        $.ajax({     	   
                url: webpath+'groups/removeadmin?groupid='+encodeURI(groupid)+'&userid='+encodeURI(userid) , 
                success:function(data){
               // window.location.reload();
               location.reload();
                 showmessage('操作成功');
                }       
             });
    }
</script>